<html>
<head><meta charset="utf-8"><title>LLVM supported versions policy · t-compiler · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/index.html">t-compiler</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/LLVM.20supported.20versions.20policy.html">LLVM supported versions policy</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="217754974"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/LLVM%20supported%20versions%20policy/near/217754974" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/LLVM.20supported.20versions.20policy.html#217754974">(Nov 24 2020 at 13:44)</a>:</h4>
<p>I read the <a href="https://rustc-dev-guide.rust-lang.org/backend/updating-llvm.html">"Upgrading LLVM"</a> page on the rustc dev guide but it wasn't clear to me how well supported older versions (like currently LLVM 9 and LLVM 10) are? For example, do all features need to be supported on all versions or just stable features? </p>
<p>This is related to <a href="https://github.com/rust-lang/rust/issues/79365">#79365</a> by <span class="user-mention" data-user-id="296355">@Rich Kadel</span>  which upgrades our LLVM code coverage feature to use V4 map files. V4 map files are not supported in LLVM 9 or LLVM 10 only LLVM 11. Currently we're using V3 which is supported by all those LLVM versions. </p>
<p>Is it acceptable to land that PR essentially restricting the feature to LLVM11+ or do we need to implement some sort of fallback logic to V3 for LLVM 9 and 10? </p>
<p>In my opinion, since this feature is backend specific anyway, it's fine for this to require a certain level of support from the linked backend especially since this is currently an unstable flag. I'm very curious to hear from others though!</p>



<a name="217755744"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/LLVM%20supported%20versions%20policy/near/217755744" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/LLVM.20supported.20versions.20policy.html#217755744">(Nov 24 2020 at 13:50)</a>:</h4>
<p>I believe the primary expectation is that generally things work -- the PR runner is using llvm 9 right now, so the test suite should pass (though min-llvm-version may exist in some cases).</p>
<p>I don't think it is absolutely necessary to support older LLVMs for coverage, but it would be good to detect them and either issue an error on use or otherwise signal that it's not supported rather than silently not working, I think.</p>



<a name="217755902"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/LLVM%20supported%20versions%20policy/near/217755902" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/LLVM.20supported.20versions.20policy.html#217755902">(Nov 24 2020 at 13:52)</a>:</h4>
<blockquote>
<p>I don't think it is absolutely necessary to support older LLVMs for coverage, but it would be good to detect them and either issue an error on use or otherwise signal that it's not supported rather than silently not working, I think.</p>
</blockquote>
<p>Yes, I strongly agree with this!</p>



<a name="217778907"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/LLVM%20supported%20versions%20policy/near/217778907" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Rich Kadel <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/LLVM.20supported.20versions.20policy.html#217778907">(Nov 24 2020 at 16:35)</a>:</h4>
<p>Perfect. I agree with that expectation too. Thanks!</p>



<a name="217812818"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/LLVM%20supported%20versions%20policy/near/217812818" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Rich Kadel <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/LLVM.20supported.20versions.20policy.html#217812818">(Nov 24 2020 at 21:01)</a>:</h4>
<p><span class="user-mention" data-user-id="125250">@Wesley Wiser</span> The modified PR now passes the initial CI. PTAL!</p>



<a name="217819028"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/LLVM%20supported%20versions%20policy/near/217819028" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> briansmith <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/LLVM.20supported.20versions.20policy.html#217819028">(Nov 24 2020 at 21:56)</a>:</h4>
<p>As for as code coverage format is concerned, I suggest that at least until the feature is stabilized, it should only be required to work with the newest stable version of clang and the newest format that that version of clang supports. This way, we avoid accumulating technical debt when the feature isn't even stable, and we minimize future maintenance on the stable channel by using the newest format at the time the feature becomes stable.</p>



<a name="217957929"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/LLVM%20supported%20versions%20policy/near/217957929" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> briansmith <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/LLVM.20supported.20versions.20policy.html#217957929">(Nov 26 2020 at 01:36)</a>:</h4>
<p>More investigation into this: <a href="https://reviews.llvm.org/D84467">https://reviews.llvm.org/D84467</a> will add support for branch coverage measurement. It requires bumping the file format version. Branch coverage measurement is really valuable. So, at least as far as code coverage is concerned, it looks like more evidence for optimizing for newer (future, even) versions of LLVM. Also, it would be very nice if there were a way to get a clang that is the same LLVM version (same code coverage file format version, in particular) as whatever LLVM that rustc is using. That way, a mixed Rust/C project could do code coverage measurement in a way that would be ~guaranteed to work.</p>



<a name="218042327"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/LLVM%20supported%20versions%20policy/near/218042327" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/LLVM.20supported.20versions.20policy.html#218042327">(Nov 26 2020 at 22:24)</a>:</h4>
<p>That's something I've been interested in as well, for different reasons.</p>



<a name="218042378"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/LLVM%20supported%20versions%20policy/near/218042378" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/LLVM.20supported.20versions.20policy.html#218042378">(Nov 26 2020 at 22:24)</a>:</h4>
<p>Wouldn't be particularly hard to compile clang along with llvm, and provide that as an additional rustup component.</p>



<a name="218042385"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/LLVM%20supported%20versions%20policy/near/218042385" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/LLVM.20supported.20versions.20policy.html#218042385">(Nov 26 2020 at 22:24)</a>:</h4>
<p>Also useful for cross language LTO.</p>



<a name="218253206"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/LLVM%20supported%20versions%20policy/near/218253206" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> briansmith <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/LLVM.20supported.20versions.20policy.html#218253206">(Nov 30 2020 at 06:44)</a>:</h4>
<p>Another issue I ran across: Currently in GitHub Actions and Ubuntu in general, it is much easier to get, say, Clang/LLVM 10 than Clang/LLVM 11 or 12. The newer versions aren't in the default repositories so you have to add a new one or install using a mechanism other than apt-get.</p>



<a name="218253253"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/LLVM%20supported%20versions%20policy/near/218253253" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> briansmith <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/LLVM.20supported.20versions.20policy.html#218253253">(Nov 30 2020 at 06:44)</a>:</h4>
<p>FWIW, as of today I am already running into "Failed to load coverage: Unsupported coverage format version" from llvm-cov-10.</p>



<a name="218290244"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/LLVM%20supported%20versions%20policy/near/218290244" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/LLVM.20supported.20versions.20policy.html#218290244">(Nov 30 2020 at 14:08)</a>:</h4>
<p><span class="user-mention" data-user-id="133214">@briansmith</span> the llvm-tools-preview component should have a llvm-cov binary in it which you can use</p>



<a name="218324429"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/LLVM%20supported%20versions%20policy/near/218324429" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> briansmith <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/LLVM.20supported.20versions.20policy.html#218324429">(Nov 30 2020 at 18:19)</a>:</h4>
<p><span class="user-mention" data-user-id="116122">@simulacrum</span> Thanks. I collect code coverage for C code as well so I need to have a compatible clang anyway.</p>



<a name="218324484"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/LLVM%20supported%20versions%20policy/near/218324484" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/LLVM.20supported.20versions.20policy.html#218324484">(Nov 30 2020 at 18:19)</a>:</h4>
<p>Yeah, we don't yet ship a clang binary though it's definitely been something we've considered. Useful data point! :)</p>



<a name="218364640"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/LLVM%20supported%20versions%20policy/near/218364640" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> briansmith <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/LLVM.20supported.20versions.20policy.html#218364640">(Dec 01 2020 at 00:09)</a>:</h4>
<p>I do wonder how diligent we'd be in maintaining the clang we distribute. Would we release out-of-band updates to Rust to address Clang-only issues, for example? Would the shipped clang use Rust's patched LLVM, and would we then maintain Clang patches to use it?</p>



<a name="218364793"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/LLVM%20supported%20versions%20policy/near/218364793" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> briansmith <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/LLVM.20supported.20versions.20policy.html#218364793">(Dec 01 2020 at 00:10)</a>:</h4>
<p>Maybe it would be easier to just have a mechanism to query the Rust toolchain to ask what major version of LLVM Rust is using, if it is using LLVM at all, so a build system can either keep the clang version in sync itself or break the build if it detects they get out of sync.</p>



<a name="218368321"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/LLVM%20supported%20versions%20policy/near/218368321" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cuviper <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/LLVM.20supported.20versions.20policy.html#218368321">(Dec 01 2020 at 00:55)</a>:</h4>
<p>if we ship clang at all, it should certainly come from the monorepo in <code>src/llvm-project</code></p>



<a name="218374850"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/LLVM%20supported%20versions%20policy/near/218374850" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/LLVM.20supported.20versions.20policy.html#218374850">(Dec 01 2020 at 02:47)</a>:</h4>
<p>The LLVM version is reported, but I wouldn't necessarily rely on it.</p>
<div class="codehilite"><pre><span></span><code>$ rustc +stable -vV
rustc 1.48.0 (7eac88abb 2020-11-16)
binary: rustc
commit-hash: 7eac88abb2e57e752f3302f02be5f3ce3d7adfb4
commit-date: 2020-11-16
host: x86_64-unknown-linux-gnu
release: 1.48.0
LLVM version: 11.0
</code></pre></div>



<a name="218376718"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/LLVM%20supported%20versions%20policy/near/218376718" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> briansmith <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/LLVM.20supported.20versions.20policy.html#218376718">(Dec 01 2020 at 03:24)</a>:</h4>
<p>Thanks. That's helpful. I wonder if it is ever a pre-release version, i.e. one where I wouldn't find an official release from <a href="http://apt.llvm.org">apt.llvm.org</a> or a release tarball from them.</p>



<a name="218378742"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/LLVM%20supported%20versions%20policy/near/218378742" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/LLVM.20supported.20versions.20policy.html#218378742">(Dec 01 2020 at 04:05)</a>:</h4>
<p>Yes, sometimes, though we sort of try to limit that on stable it's not currently a strong commitment - I think 1.47 shipped LLVM 11 while it was in prerelease.</p>



<a name="218460673"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/LLVM%20supported%20versions%20policy/near/218460673" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cuviper <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/LLVM.20supported.20versions.20policy.html#218460673">(Dec 01 2020 at 18:16)</a>:</h4>
<p>long ago, we sometimes even had arbitrary snapshots of LLVM trunk, but more recently we've at least waited until there's a release candidate</p>



<a name="218460728"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/LLVM%20supported%20versions%20policy/near/218460728" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cuviper <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/LLVM.20supported.20versions.20policy.html#218460728">(Dec 01 2020 at 18:16)</a>:</h4>
<p>that's _probably_ good enough for matching data formats, but it's still possible for things to change from rc to release</p>



<a name="218474495"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/LLVM%20supported%20versions%20policy/near/218474495" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> briansmith <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/LLVM.20supported.20versions.20policy.html#218474495">(Dec 01 2020 at 20:10)</a>:</h4>
<p>I think users will want to use a final release of clang + a final release of Rust and get the code coverage to work.</p>



<a name="218475921"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/LLVM%20supported%20versions%20policy/near/218475921" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> briansmith <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/LLVM.20supported.20versions.20policy.html#218475921">(Dec 01 2020 at 20:21)</a>:</h4>
<p>Especially, in a mixed-language project, very unlikely C and C++ programmers will trust a Rust-provided version of Clang. I hope we can find a way to get Rust's changes to LLVM upstreamed quickly on a regular basis so that production releases of both Clang and Rust can interoperate, not just for code coverage, but for profiling and LTO.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>